import numpy as np
from ortools.constraint_solver import routing_enums_pb2
from ortools.constraint_solver import pywrapcp

np.set_printoptions(suppress=True, linewidth=999)


def create_data_model(file_path):
    raw = np.loadtxt(file_path, skiprows=6, encoding='utf-8', dtype=float)
    res_data = dict()
    res_data['num_indexes'] = len(raw)
    i = np.arange(len(raw))
    j = i.reshape(len(i), -1)
    res_data['distance_matrix'] = np.sqrt((raw[:, 1][i] - raw[:, 1][j])**2 + (raw[:, 2][i] - raw[:, 2][j])**2)
    res_data['num_vehicles'] = 1
    res_data['depot'] = 0
    return res_data


if __name__ == '__main__':
    data = create_data_model('../../data/TSPLIB/burma14.tsp.txt')
    manager = pywrapcp.RoutingIndexManager(data['num_indexes'], data['num_vehicles'], data['depot'])
    model = pywrapcp.RoutingModel(manager)


    def distance_callback(from_index, to_index):
        print()

